import axios from '@/utils/request'

/**
 *发起流程 
 * 
 */
//获取数据列表
export const getInitializationTableDataAysnc = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/flowDefinition/latestList?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}


//获取xml 查看流程图或查看xml
export const getflowChartXMLAsync = (params) => {
  const { procDefId } = params
  return axios.get(`/lanlu/flowDefinition/flowXML?procDefId=${procDefId}`)
}

//发起流程
export const postFLowInfoAsync = (params) => {
  const { id, ...otherInfo } = params
  return axios.post(`/lanlu/instance/startFlow/${id}`, otherInfo)
}

//保存数据 发起流程后 接着保存数据
export const saveFormDataAsync = (params) => {
  return axios.post(`/lanlu/instance/saveFromValue`, params)
}


/**
 * 我发起的流程 
 */

//获取数据列表
export const getMyInitializationTableDataAysnc = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/instance/myStartProcess?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}


//删除流程
export const deletedFLowAysnc = (params) => {
  const { proInstId } = params
  return axios.delete(`lanlu/instance/delProcessInst/${proInstId}`)
}

/**
 * 我发起的 
 */

//获取数据列表
export const getMyTaskListAsync = (params) => {
  return axios.get(`/lanlu/task/getMyTasks?key=${params.key}`)
}

//领取任务
export const getToDoTask = (params) => {
  return axios.get(`/lanlu/task/getToDoTask?taskId=${params.taskId}`)
}

/**
 * 待我审批
 * 
*/

//获取数据列表
export const getMyToDoTaskListAsync = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/task/myToDoTask?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}

//审批
export const approveTaskAsync = (params) => {
  return axios.post('/lanlu/task/completeFlow', params)
}

/***
 * 我已审批
 * 
 */

//获取数据列表
export const getCompleteTaskListAsync = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/task/finishedList?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}


//查看我已经审批的节点流程图
export const getCompleteFlowChartAsync = (params) => {
  const { processId } = params
  return axios.get(`/lanlu/task/myFlowImg?processId=${processId}`)
}